//
//  ConsultDetailTableViewCell.m
//  110
//
//  Created by lanou on 16/4/11.
//  Copyright © 2016年 乔砥. All rights reserved.
//

#import "ConsultDetailTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "NSString+Html.h"
@interface ConsultDetailTableViewCell ()
@property (nonatomic, strong) UIWebView *qiaodi;

@property(nonatomic,assign)NSInteger  hight;
@end
@implementation ConsultDetailTableViewCell





-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
   
        
        
        
        
        self.myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, KWIDTH, KHEIGHT / 3)];
        [self.contentView addSubview:_myImageView];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, KHEIGHT / 3 +10 , KWIDTH-20, 60)];
        self.titleLabel.numberOfLines = 0;

        [self.contentView addSubview:_titleLabel];
        
        
        self.addTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, KHEIGHT / 3 +10+60, 100, 30)];
        [self.contentView addSubview:_addTimeLabel];
        
        
        
        
        
        _qiaodi = [[UIWebView alloc]initWithFrame:CGRectMake(10, KHEIGHT / 3 +10+60+30, KWIDTH - 20, KHEIGHT)];
        _qiaodi.scrollView.scrollEnabled = NO;
        [self.contentView addSubview:_qiaodi];
        
       
        
    }
    
    return self;
    
    
}


-(void)getData:(ConsultDetailViewControllerModel *)model
{
    _titleLabel.text = model.title;
    _addTimeLabel.text = model.addTime;
    [_qiaodi loadHTMLString:model.content baseURL:[NSURL fileURLWithPath:[NSBundle mainBundle].bundlePath]];
    
    
    [_myImageView sd_setImageWithURL:[NSURL URLWithString:model.thumbnail]];
    
    
    CGRect bound2 = [model.content boundingRectWithSize:CGSizeMake(KWIDTH-20, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:16] forKey:NSFontAttributeName] context:nil];
    
    

    _qiaodi.frame = CGRectMake(10, KHEIGHT / 3 +10+60+30, KWIDTH - 20, bound2.size.height + 600);
    
    
}




+(CGFloat)cellHeghtForRow:(ConsultDetailViewControllerModel *)model
{
    
    
    
    CGRect bound2 = [model.content boundingRectWithSize:CGSizeMake(KWIDTH-20, 10000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:16] forKey:NSFontAttributeName] context:nil];
    return KHEIGHT / 3 +10+60+10+30+10 +bound2.size.height + 600;
    
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
